package com.dl.chat.mapper;


import com.dl.chat.entity.ChatHistory;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface ChatHistoryMapper  {
    @Insert("INSERT INTO chat_history (user_id, role, content, created_at) " +
            "VALUES (#{userId}, #{role}, #{content}, #{createdAt})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(ChatHistory chatHistory);

    @Select("SELECT * FROM chat_history WHERE user_id = #{userId}")
    List<ChatHistory> selectByUserId(String userId);

    @Delete("DELETE FROM chat_history WHERE id = #{id}")
    void deleteById(Long id);
}
